package com.example.demo.firemain.data;




import com.example.demo.firemain.ByteUtil;
import com.example.demo.firemain.NumConstant;
import lombok.Data;


/**
 * 火灾主要状态操作
 * 消防主机操作信息 -操作员作为消防主机编号
 *
 * @author TDS
 * @date 2022/08/23
 */
@Data
public class FireMainStatusOperation{

	/**
	 * 系统类型//消防主机类型
	 */
	private Integer systemType;
	/**
	 * 系统代码///消防主机编号
	 */
	private Integer systemCode;
	/**
	 * 地位名字//消防主机状态
	 */
	private String statusName;

	/**
	 * 设备id
	 */
	private String device_id;

    public FireMainStatusOperation(String data , String deviceId){
    	this.device_id = deviceId;


		systemType = Integer.parseInt(data.substring(4,6),16);
		systemCode = Integer.parseInt(data.substring(6,8),16);
		String bit = ByteUtil.buqi2(Integer.toBinaryString(Integer.parseInt(data.substring(8,10),16)));

		if (NumConstant.ONE.equals(bit.substring(1,2))){
			statusName = "测试";
		}else if (NumConstant.ONE.equals(bit.substring(2,3))){
			statusName = "确认";
		}else if (NumConstant.ONE.equals(bit.substring(3,4))){
			statusName = "自检";
		}else if (NumConstant.ONE.equals(bit.substring(4,5))){
			statusName = "警情消除";
		}else if (NumConstant.ONE.equals(bit.substring(5,6))){
			statusName = "手动报警";

		}else if (NumConstant.ONE.equals(bit.substring(6,7))){
			statusName = "消音";
		}else if (NumConstant.ONE.equals(bit.substring(7,8))){
			statusName = "复位";
		}


    }

}
